package com.dkm.biz.gl.domain;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.biz.domain.AbstractDomain;
import com.dkm.biz.gl.persistence.dao.GlTextDao;
import com.dkm.biz.gl.persistence.entity.GlTextPo;

/**
 * 对象功能:c6_gl_text 领域对象实体
 * 开发公司:唯心六艺软件 - Craft6.cn
 * 开发人员:winston
 * 创建时间:2014-05-26 08:26:10
 */
@Service
public class GlText extends AbstractDomain<String, GlTextPo>{
	 
	 private GlTextDao glTextDao = null;
	 
	protected void init(){
		glTextDao = SpringHelper.getBean(GlTextDao.class);
		setDao(glTextDao);
	}	 
	 
	public String saveText(String text_) {
		getData().setType(GlTextPo.TYPE_DB);
		if(StringUtils.isNotEmpty(text_))text_ = text_.replaceAll("\n", "\\n");
		getData().setText(text_);		
		save();
		return getId();
	}
	
	public String saveFile(String text_){
		getData().setType(GlTextPo.TYPE_DISK);
		//TODO 持久化到硬盘，设计一个帮助类，调用保存内容到文件
		String path = "";
		getData().setPath(path);
		save();
		return getId();
	}
}
